﻿@using A2.ERP.Models
@{
    //库房
    List<t_StoreHouse> houselist = ViewBag.HouseList;
    //库区
    List<t_StoreHouseDetail> detail = ViewBag.HouseDetail;
    //
    t_BuyReceipt receipt = ViewBag.receipt;
    //添加入库
    List<p_BuyReceipt_getAdminBuyReceiptOrderList_Result> data = ViewBag.data;
    t_Products pro = ViewBag.Product;
}
<section id="ModuleBuyReceip">

    <style type="text/css">
        input, select {
            margin-right: 100px;
            width: auto;
        }

        .nomargin {
            margin: 0px;
        }

        .long {
            width: 500px;
            margin-right: 50px;
        }

        #BuyReceipGood,#ReceiptData {
            display: none;
        }
    </style>
    <div id="BuyReceip">
        <div class="card-header">采 购 入 库</div>
        <div class="card-body">
            @using (Html.BeginForm("ModuleBuyReceip", "Purchase", FormMethod.Post, new
            {
                @class = "form addBuyReceip"
            }))
            {
                <div class="form-group">
                    <div class="input-group mb-3">
                        <div class="input-group-prepend">
                            <span class="input-group-text">订单编号</span>
                        </div>
                        <input type="text" name="ReceiptOrderID" value="@receipt.ReceiptOrderID"/>
                        <div class="input-group-prepend">
                            <span class="input-group-text">制单日期</span>
                        </div>
                        <input type="date" name="ReceiptOrderDate" />
                        <div class="input-group-prepend">
                            <span class="input-group-text">订单入库</span>
                        </div>
                        <select name="BuyOrderID">
                            @foreach (var item in data)
                            {
                                <option value="@item.BuyOrderID" id="BuyOrderID">@item.BuyOrderID</option>
                            }
                        </select>
                    </div>
                    <div class="form-group">
                        <div class="input-group mb-3">
                            <div class="input-group-prepend">
                                <span class="input-group-text">库房</span>
                            </div>
                            <select name="StoreHouseID" class="nomargin">
                                @foreach (var item in houselist)
                                {
                                    <option value="@item.HouseID" onclick="ChangeHouse(@item.HouseID)">@item.HouseName</option>
                                }
                            </select>
                            <div class="input-group-prepend">
                                <span class="input-group-text">库区</span>
                            </div>
                            <select name="HouseDetailID">
                                @foreach (var item in detail)
                                {
                                    <option value="@item.ID">@item.SubareaName</option>
                                }
                            </select>
                            <div class="input-group-prepend">
                                <span class="input-group-text">入库时间</span>
                            </div>
                            <input type="date" name="TradeDate" />
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="input-group mb-3">
                            <div class="input-group-prepend">
                                <span class="input-group-text">备注</span>
                            </div>
                            <input type="text" name="Description" class="nomargin long" />
                            <input type="submit" value="生成采购入库单" class="btn btn-primary none">
                            <input value="删除该单" class="btn btn-primary block nomargin" style="display: none" type="button" />
                            <input value="完成所有" class="btn btn-primary block" style="display: none" type="button" />
                        </div>
                    </div>

                </div>
                
            }
        </div>
    </div>
    @* 商品 *@


    <div id="BuyReceipGood">
        <div class="card-header">商 品 信 息</div>
        <div class="card-body">
            <div class="form-group">
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text">商品</span>
                    </div>
                    <input type="text" name="" />
                    <div class="input-group-prepend">
                        <span class="input-group-text">价钱</span>
                    </div>
                    <input type="number" name="" />
                    <div class="input-group-prepend">
                        <span class="input-group-text">数量</span>
                    </div>
                    <input type="number" name="" value="0" />
                </div>
            </div>
            <div class="form-group">
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text">税率%</span>
                    </div>
                    <input type="number" step="0.00" value="0.00" name="" />
                    <div class="input-group-prepend">
                        <span class="input-group-text">折扣率%</span>
                    </div>
                    <input type="number" step="0.00" value="0" name="" />
                    <div class="input-group-prepend">
                        <span class="input-group-text">供应商</span>
                    </div>
                    <input type="text" name="" />
                </div>
            </div>
            <div class="form-group">
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text">描述</span>
                    </div>
                    <input type="text" name="" class="nomargin long" /><input type="submit" value="保存" class="btn btn-primary" />
                </div>
            </div>
        </div>
    </div>

    @* 数据表显示 *@
    <div id="Data">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th>操作</th>
                    <th>商品编号</th>
                    <th>商品名称</th>
                    <th>供应商</th>
                    <th>数量</th>
                    <th>采购额</th>
                    <th>折扣额</th>
                    <th>税额</th>
                    <th>金额</th>
                </tr>
            </thead>
            <tbody>
                @if (pro != null)
                {
                       <tr>
                        <td><a data-route="" class="btn btn-primary btn-sm text-white">
                            <i class="icon SkyUI icon-edit"></i>
                            编辑
                        </a><a data-route="" class="btn btn-success btn-sm text-white">
                            <i class="icon SkyUI icon-remove"></i>
                            删除
                        </a>@pro.ProductsID</td>
                        <td>@pro.ProductsName</td>
                        <td>@pro.</td>
                        <td>@pro.</td>
                        <td>@pro.</td>
                        <td>@pro.</td>
                        <td>@pro.</td>
                        <td>@pro.</td>
                        <td>@pro.</td>
                    </tr> 
                    
                    
                }

            </tbody>
        </table>
    </div>
    
</section>
<script type="text/javascript">
    ;
    !function () {
        var $addBuyReceipFrm = $('#ModuleBuyReceip .addBuyReceip');
        $addBuyReceipFrm.submit(function (e) {
            e.preventDefault();
            $addBuyReceipFrm.ajaxSubmit({
                type: 'POST',
                dataType: 'json',
                success: function (e) {
                    //$tab.reloadTab('#ModuleBuyReceip');
                    //显示剩下按钮和商品信息
                    $("#BuyReceipGood").css("display", "block");
                    $("#ReceiptData").css("display", "block");
                    $(".none").css("display", "none");
                    $(".block").css("display", "inline-block");
                    //$.ajax({
                    //    type:'post',
                    //    url: '../Purchase/ModuleBuyReceip',
                    //    data: $("select[name='BuyOrderID']").val(),
                    //    success: function (e) {
                    //        alert("sdfg");
                    //    }
                    //});
                }
            });
        });
    }();
    //选择库房
    function ChangeHouse(id) {
        $('.modal').modal('hide');
        $tab.reloadTab('#ModuleBuyOrder', [{ id: id }]);
        $tab.reloadTab('#ModuleBuyReceip', [{ id: id }]);

    };
    //库区库房选择完毕
    function changeID(House, ID) {
        ////关闭选项窗体
        //库房和库区的id
        $("input[name='StoreHouseID']").val(House);
        $("input[name='HouseDetailID']").val(ID);
    };
   
   

</script>
